package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.Dashboard;
import com.woniu.cinema.service.DashboardService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 票房榜单Controller
 *
 * @author yy
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/cinema/dashboard")
public class DashboardController extends BaseController
{
    @Autowired
    private DashboardService dashboardService;

    /**
     * 查询票房榜单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Dashboard dashboard)
    {
        startPage();
        List<Dashboard> list = dashboardService.selectDashboardList(dashboard);
        return getDataTable(list);
    }
    @GetMapping("web/list")
    public TableDataInfo weblist(Dashboard dashboard)
    {
        startPage();
        List<Dashboard> list = dashboardService.selectDashboardList(dashboard);
        return getDataTable(list);
    }

    /**
     * 导出票房榜单列表
     */
    @Log(title = "票房榜单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Dashboard dashboard)
    {
        List<Dashboard> list = dashboardService.selectDashboardList(dashboard);
        ExcelUtil<Dashboard> util = new ExcelUtil<Dashboard>(Dashboard.class);
        return util.exportExcel(list, "dashboard");
    }

    /**
     * 获取票房榜单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(dashboardService.selectDashboardById(id));
    }

    /**
     * 新增票房榜单
     */
    @Log(title = "票房榜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dashboard dashboard)
    {
        return toAjax(dashboardService.insertDashboard(dashboard));
    }

    /**
     * 修改票房榜单
     */
    @Log(title = "票房榜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dashboard dashboard)
    {
        return toAjax(dashboardService.updateDashboard(dashboard));
    }

    /**
     * 删除票房榜单
     */
    @Log(title = "票房榜单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(dashboardService.deleteDashboardByIds(ids));
    }
}
